how to make dissapear an object in unity

302

how to make dissapear an object in unity -

public class Player : MonoBehaviour
{
    //Set this game object by dragging on UI
    public GameObject body;

    private void OnCollisionEnter2D(Collision2D other) {
      if(body != null){
        body.GetComponent<Renderer>().enabled = false;
        Destroy(body);
      }
    }
}

Comments

Submit
0 Comments